import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import axios from 'axios';
axios.defaults.withCredentials = true//带上cookies
axios.defaults.baseURL = 'http://localhost:8848/dms/'
//设置拦截器
axios.interceptors.response.use(
    response=>{
        let result = response.data;
        //未登录
        if (result.status == 402) {
            // Vue.prototype.$message.error(result.message)
            router.push({name: 'Login'})
        }
        //无权限
        if (result.status == 401) {
            Vue.prototype.$message.error(result.message)
        }
      return response;
    }
)


Vue.prototype.$axios = axios




import Qs from 'qs';//把默认axios  json格式传参形式变成key value的形式
Vue.prototype.$Qs = Qs;//this.$Qs.stringify(params);

Vue.use(ElementUI)

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
